//package com.glsc.ngateway.flowable.config;
//
//import com.alibaba.druid.pool.DruidDataSource;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//
//@Configuration
//public class DruidDataSourceConfiguration {
//    @Autowired
//    private DruidDataSourceProperties properties;
//    @Bean(name = "druidDataSource", initMethod = "init", destroyMethod = "close")
//    @Primary
//    @Qualifier("druidDataSource")
//    public DataSource dataSource() throws Exception {
//        DruidDataSource druidDataSource = new DruidDataSource();
//        druidDataSource.setUrl(properties.getUrl());
//        druidDataSource.setUsername(properties.getUsername());
//        druidDataSource.setPassword(properties.getPassword());
//        druidDataSource.setDriverClassName(properties.getDriverClassName());
//        druidDataSource.setInitialSize(properties.getInitialSize());
//        druidDataSource.setMaxActive(properties.getMaxActive());
//        druidDataSource.setMinIdle(properties.getMinIdle());
//        druidDataSource.setMaxWait(properties.getMaxWait());
//        druidDataSource.setTimeBetweenEvictionRunsMillis(properties
//                .getTimeBetweenEvictionRunsMillis());
//        druidDataSource.setMinEvictableIdleTimeMillis(properties
//                .getMinEvictableIdleTimeMillis());
//        druidDataSource.setValidationQuery(properties.getValidationQuery());
//        druidDataSource.setTestWhileIdle(properties.isTestWhileIdle());
//        druidDataSource.setTestOnBorrow(properties.isTestOnBorrow());
//        druidDataSource.setTestOnReturn(properties.isTestOnReturn());
//        druidDataSource.setPoolPreparedStatements(properties
//                .isPoolPreparedStatements());
//        druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(properties
//                .getMaxPoolPreparedStatementPerConnectionSize());
//        druidDataSource.setFilters(properties.getFilters());
//        try {
//            if (null != druidDataSource) {
//                druidDataSource.setFilters("wall,stat");
//                druidDataSource.setUseGlobalDataSourceStat(true);
//                Properties properties = new Properties();
//                properties.setProperty("decrypt", "true");
//                druidDataSource.setConnectProperties(properties);
//                druidDataSource.init();
//            }
//        } catch (Exception e) {
//            throw new RuntimeException(
//                    "load datasource error, dbProperties is :", e);
//        }
//        return druidDataSource;
//    }
//}
